STEPPER MOTOR INTERFACING WITH RASPBERRY Pi
In this project we will learn how to interface stepper motor with Raspberry Pi. Stepper motor is an electromechanical device that converts electrical energy into mechanical rotation.
Synopsis:

In this project we will learn how to interface stepper motor with Raspberry Pi. Stepper motor is an electromechanical device that converts electrical energy into mechanical rotation.

Description


Stepper Motor:

Stepper motor can divide one complete rotation into a discrete number of steps. These motors are quite similar to switched reluctance motors. Stepper motor makes the motor shaft turn in the specific distance when the pulse of electricity is provided. There are three types of stepper motors they are.

1.Permanent magnet (PM) stepper motor:

It uses a permanent magnet in the rotor. It operates based on attraction or repulsion between rotor permanent magnet and stator electromagnetic poles.

2.Variable reluctance (VR) stepper motor:

It has a plain iron rotor. When the minimum reluctance occurs with a minimum gap then the rotor points attract to the stator magnetic poles.

3.Hybrid Synchronous stepper motor:

It is named as hybrid stepper motor because it is a combination of permanent magnet and variable reluctance techniques which is used to achieve maximum power with a small size package.

Based on the stator windings stepper motor is classified into two categories.

1.Unipolar stepper motor:

It has two coils with 5 or 6 or 8 leads, there one winding with a center tap connection that allows current flow in half winding at a time. Unipolar has less torque and is less efficient

2.Bipolar stepper motor:

It has two coils with 4 leads, there is only single winding per phase that allows current flow through entire winding at a time compared with unipolar stepper motor bipolar stepper motor is more efficient and has more torque.

Raspberry Pi:

Raspberry Pi is a low cost, small size computer that plugs into a computer monitor, and uses a keyboard and mouse. It is capable device that enables us to explore computing and to learn how to program in languages like scratch and python. It is capable of doing what we expect a computer to do. It has many interfaces like HDMI, multiple USB, Ethernet, onboard Wi-Fi and Bluetooth, GPIOs, USB powered etc. also supports to LINUX, Python to make easy to build applications. Raspberry is available in different versions the latest version of Raspberry Pi is Pi3+ Model and the Updated version is Pi4 model. In Raspberry Pi 3B+ Model this model is having 64-bit quad core (processor) running at 1.4GHz, dual band 2.4GHz, 5GHz wireless LAN, Bluetooth 4.2/BLE, faster Ethernet, and PoE (power on Ethernet) capability with separate PoE HAT. Raspberry Pi3 Mode B+ maintains the same footprint as raspberry Pi2 and Raspberry Pi3 Model B.


Pin configuration:

1. Vin: Two 5v pins and two 3v3 pins used for providing power supply, where processor works on 3.3v.

2. Ground: Having 8 ground Pins which are un-configurable.

3. GPIO: There are 26 input-output pins which will be used as input or output based on programming.

4. PWM: In software PWM are available for all pins but in hardware PWM is available for GPIO12, GPIO13, GPIO18, and GPIO19.

5. 2 SPI bus: These pins are used for SPI communication the pins which are used for SPI is MISO, MOSI, SCLK, CE0, and CE1

6. I2C: These pins are used for I2C communication in which DATA and CLOCK pins are used for sending data to and from the SDA connection, with the speed controlled with SCL pin and ID-SE, ID-SC are reserved for ID EEPROM.

7. TX and RX: This pins are used for UART communication.

Schematic:


Code:

import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(16, GPIO.OUT)
GPIO.setup(18, GPIO.OUT)
While 1:
	x = 1
	GPIO.OUTPUT(16, 1)  # SETS THE MOTOR CLOCK-WISE DIRECTION
	for x in range(200):
		GPIO.OUTPUT(18, 1)
		time.sleep(0.5)
		GPIO.OUTPUT(18, 0)
		time.sleep(0.5)
	time.sleep(1)
	GPIO.OUTPUT(16, 0)  # SETS THE MOTOR ANTI-CLOCK-WISE DIRECTION
	for x in range(400):
		GPIO.OUTPUT(18, 1)
		time.sleep(0.5)
		GPIO.OUTPUT(18, 0)
		time.sleep(0.5)
	time.sleep(1)


Error message here!

Show Error message here!


Forgot your password?

Error message here!

Send OTP

Error message here!

Show Error message here!


Lost your password? Please enter your email address. You will receive a password you Need.

Send Error message here!


Back to log-in

Close